{include file="public/head"/}
<div class="layui-fluid" id="LAY-app-message">
    <div class="layui-card">
        <div class="layui-card-header">用户组列表</div>
        <div class="layui-card-body layui-text">
            <table class="layui-table" id="group" lay-filter="group"></table>
        </div>
    </div>
</div>
{include file="public/foot"/}
<script type="text/html" id="group_action">
    <button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="groupAccess"><i class="layui-icon layui-icon-table"></i>配置权限</button>
    <button class="layui-btn layui-btn-xs" lay-event="group_edit"><i class="layui-icon layui-icon-edit"></i>编辑</button>
    <button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="group_del"><i class="layui-icon layui-icon-delete"></i>删除</button>
</script>
<script type="text/html" id="toolbarGroup">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon layui-icon-add-1"></i>添加用户组</button>
    </div>
</script>
<script>
    layui.config({
        base: '__LAYDMIN__/',{if config('app.app_debug')}version: true{/if}
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'admin', 'table', 'util','form','treeGrid'],function(){
		var $ = layui.$, admin = layui.admin, table = layui.table, element = layui.element,form = layui.form,treeGrid = layui.treeGrid, tableId='list';
		   var util = layui.util;
		   var tableLoadDiv = window.top.layer.load(0,{shade:[0.15, '#000']}); //加载层,table.render完成时需要关闭
		//权限列表
			tableIn = table.render({
				elem: '#group',
				url: '{:url(SYS_PATH."/authGroup/index")}',
				toolbar: '#toolbarGroup',
				defaultToolbar:'',
				method: 'post',
				cols: [[
					{field:'group_id', title: 'ID',width:80, fixed: true,sort: true},
					{field:'title', title: '用户组名', width:180},
					{field:'create_time', title: '添加时间', width:200,sort: true,
										templet:function(d){
													return util.toDateString(d.create_time*1000, "yyyy-MM-dd HH:mm:ss");
										}
					},
					{width:260, align:'center',toolbar:'#group_action'}
				]],
				done:function (res) {   //返回数据执行回调函数
						window.top.layer.close(tableLoadDiv);    //返回数据关闭loading
				}				
			});
		 
		table.on('toolbar(group)', function(obj){
			if(obj.event=='add'){
				layui.layerOpen("{:url(SYS_PATH.'/authGroup/add')}");
			}
		});	
		
		//列表编缉与删除---监听工具条
		table.on('tool(group)', function (obj) {
				var data = obj.data;
					var id = data.group_id;
					if (obj.event === 'group_del') {
						var uri="{:url(SYS_PATH.'/authGroup/doDelete')}"
						layui.doDelete(uri,"您确定要删除该角色吗？",id,obj);//单个删除接口
					}else if (obj.event === 'group_edit') {
						layui.layerOpen("{:url(SYS_PATH.'/authGroup/edit')}?id="+id);
					}else if (obj.event === 'groupAccess') {
						layui.layerOpen("{:url(SYS_PATH.'/authGroup/access')}?id="+id);
					}
		});	

	});
</script>
</body>
</html>